package com.isdepci.project.carbon.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.project.carbon.domain.EmissionPathLog;
import com.isdepci.project.carbon.service.IEmissionPathLogService;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.web.page.TableDataInfo;

/**
 * 减排路径记录Controller
 *
 * @author isdepci
 * @date 2024-11-12
 */
@RestController
@RequestMapping("/carbon/emissionPathLog")
public class EmissionPathLogController extends BaseController
{
    @Autowired
    private IEmissionPathLogService emissionPathLogService;

    /**
     * 查询减排路径记录列表
     */
    @PreAuthorize("@ss.hasPermi('carbon:emissionPathLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(EmissionPathLog emissionPathLog)
    {
        startPage();
        List<EmissionPathLog> list = emissionPathLogService.selectEmissionPathLogList(emissionPathLog);
        return getDataTable(list);
    }

    /**
     * 导出减排路径记录列表
     */
    @PreAuthorize("@ss.hasPermi('carbon:emissionPathLog:export')")
    @Log(title = "减排路径记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(EmissionPathLog emissionPathLog)
    {
        List<EmissionPathLog> list = emissionPathLogService.selectEmissionPathLogList(emissionPathLog);
        ExcelUtil<EmissionPathLog> util = new ExcelUtil<EmissionPathLog>(EmissionPathLog.class);
        return util.exportExcel(list, "emissionPathLog");
    }

    /**
     * 获取减排路径记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('carbon:emissionPathLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(emissionPathLogService.selectEmissionPathLogById(id));
    }

    /**
     * 新增减排路径记录
     */
    @PreAuthorize("@ss.hasPermi('carbon:emissionPathLog:add')")
    @Log(title = "减排路径记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmissionPathLog emissionPathLog)
    {
        return toAjax(emissionPathLogService.insertEmissionPathLog(emissionPathLog));
    }

    /**
     * 修改减排路径记录
     */
    @PreAuthorize("@ss.hasPermi('carbon:emissionPathLog:edit')")
    @Log(title = "减排路径记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmissionPathLog emissionPathLog)
    {
        return toAjax(emissionPathLogService.updateEmissionPathLog(emissionPathLog));
    }

    /**
     * 删除减排路径记录
     */
    @PreAuthorize("@ss.hasPermi('carbon:emissionPathLog:remove')")
    @Log(title = "减排路径记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(emissionPathLogService.deleteEmissionPathLogByIds(ids));
    }
}
